package com.djx.locks;

import com.djx.lianxi;
import org.junit.Test;

public class Test00 {


    private void sell() {
        System.out.println("售票开始!");

        int sleepMillis = 1000;

        try {
            Thread.sleep(sleepMillis);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("售票结束!");
    }

    public void sellTicketWithLock() throws Exception {

        lianxi lock = new lianxi();
        lock.acquireLock();
        sell();
        lock.releaseLock();

    }

    @Test
    public void one() throws Exception {
        Test00 test00 = new Test00();

        for (int i = 0; i < 10; i++) {
            System.out.println("1111111111111111");
            test00.sellTicketWithLock();
        }
    }

    @Test
    public void two() throws Exception {
        Test00 test00 = new Test00();

        for (int i = 0; i < 10; i++) {
            System.out.println("22222222222222222");
            test00.sellTicketWithLock();
        }
    }


}
